﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Qcdz.Domain.Membership;
using Ue.Qcdz.Domain.Roles;

namespace Ue.Qcdz.Domain.Permissions
{
    public class PermissionsService
    {
        private static IPermissionsRepository _repository;
        static PermissionsService()
        {
            PermissionsService._repository = RepositoryFactory.GetRepository<IPermissionsRepository, Permission>();
        }

        public static Permission GetPermissions(object permissionsKey)
        {
            return PermissionsService._repository.FindBy(permissionsKey);
        }
        public static IList<Permission> GetPermissions()
        {
            return PermissionsService._repository.FindAll();
        }
        public static IDataResult<Permission> GetPermissions(IDataQuery dataQuery)
        {
            return PermissionsService._repository.FindBy(dataQuery);
        }
        public static void Addpermission(Permission permissions)
        {
            PermissionsService._repository.Add(permissions);
        }
        public static void DelePermision(Role role)
        {
            PermissionsService._repository.Delete(role);
        }

        public static void UpdatePermission(Permission permissions)
        {
            PermissionsService._repository[permissions.Key] = permissions;
        }
    }
}
